package com.mobile.challenge.ui.report.utils

import androidx.fragment.app.Fragment
import com.mobile.challenge.bean.AdminWeekMonthDataBean
import com.mobile.challenge.ui.report.model.PagerFragmentModel
import com.mobile.challenge.ui.report.my.MyReportFragment
import com.mobile.challenge.ui.report.unit.admin.AdminUnitReportFragment
import com.mobile.challenge.ui.report.unit.admin.weekmonth.AdminHistogramFragment
import com.mobile.challenge.ui.report.unit.manager.ManagerUnitReportFragment
import com.mobile.challenge.user.UserHelper
import com.mobile.challenge.user.UserType

/**
 * @Author Touge
 * @Date 2020/9/15 22:33
 * @Description
 */
object ReportPagerUtils {

    fun getReportFragmentPager(): ArrayList<PagerFragmentModel> {
        val list = ArrayList<PagerFragmentModel>(0)

        list.add(PagerFragmentModel("My Report", MyReportFragment.newInstance()))

        val userType = UserHelper.getInstance().getUserType()
        if (userType == UserType.MANAGER) {
            list.add(PagerFragmentModel("Unit Report", ManagerUnitReportFragment.newInstance()))
        } else if (userType == UserType.ADMIN) {
            list.add(PagerFragmentModel("Unit Report", AdminUnitReportFragment.newInstance()))
        }

        return list
    }

    fun getHistogramFragmentList(unitIdList: List<AdminWeekMonthDataBean>): ArrayList<Fragment> {
        val list = ArrayList<Fragment>(0)
        for (unitId in unitIdList) {
            list.add(AdminHistogramFragment.newInstance(unitId.unitName))
        }
        return list
    }

}